<?php
	/**
	*	File name : file1.php
	*	Created : 17-Febrauary 2012 
	**/
	 
	// this file is basic php examples
	
	// this is single line comment "//"
	
	# This is also sinle line comment
	
	/*
		this is multi line comment
		
	*/
	
	
	function parseIP($string){
        //if(preg_match('/(.+?)-*\s*Attachment\s*\d*\s*/si',$string,$matches)){
            //$string = $matches[1];
        //}
        /*if(preg_match('/(\s+[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})/s',$string,$matches)){
           return trim($matches[0]);
        }*/
        if(preg_match('/([^V][0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})/s',$string,$matches)){
            $temp = $matches[0][0];
            if(is_int($temp)){
                $return = $temp;
            }
            else{
                $return = substr($matches[0],1);
            }
            return $return;
        }
    }
	
	$string = "Testing please ignore this ticket:FW:Clean_homes_are_happy homes____ IP Found: 184.154.157.179 IP Found: 173.236.116.78 IP Found: 173.236.116.72 IP Found: 173.236.116.75 IP Found: 173.236.116.70  ";
	
	echo parseIP($string);
	
	exit; //program will exit 
	
	$a = 1; // variable assignment,each line in php ends with semi colon (;)
	
	/*
		There is no data type in php if you assign integer to variable, then
		variable will be integer, if you assign string , variable will become
		string
	*/
	
	$b = "value of b is this string"; //assigning string to variable
	
	echo $b; //dispalying value of variable $b
	//output :  value of b is this string
	
	print ($b); //print is also used for disaplying
	//output :  value of b is this string
	
	echo $a.$b; // String concat , which used dot(.) for caoncat
	//output :  1value of b is this string
	
	
	
	/* Just ubersmith api */
	include "class.uber_api_client.php";
    $api_client = new uber_api_client("https://uebr api url/","api_user","api_pass");
	try{
		$result = $api_client->call('support.ticket_update',array(
			'ticket_id'=>11111,
			'q_id'=>1111
		));
		echo $result;
	}catch(Exception $e){
		echo "Can't updated ticket department. API Error: ".$e-getMessage()."(".$e-getCode().")\n";
	}
	
	echo "end";
	exit;
	
	
	
	show_source("index.php");
	
	
?>